package com.example.campuslink.commen.adpter

import android.util.Log
import android.widget.ImageView
import android.widget.TextView
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.example.campuslink.BR
import com.example.campuslink.R
import com.example.campuslink.commen.core.CoreAdapter
import com.example.campuslink.commen.core.CoreViewHolder
import com.example.campuslink.commen.db.userInfo.UserInfoTable
import com.example.campuslink.databinding.AdapterCallUserBinding

import com.example.campuslink.viewModel.PublicViewModel

class CallUserListAdapter(vm: PublicViewModel) :
    CoreAdapter<AdapterCallUserBinding, PublicViewModel, UserInfoTable>(
        BR.data,
        BR.viewModel,
        vm
    ) {
    override fun getItemLayoutId(viewType: Int): Int {
        return R.layout.adapter_call_user
    }

    override fun onBindViewHolder(holder: CoreViewHolder, position: Int) {
        super.onBindViewHolder(holder, position)
        Glide.with(holder.itemView.context).load(mListData[position].userAvatar)
            .error(R.drawable.ic_empty)
            .apply(RequestOptions.circleCropTransform())
            .into(holder.binding.root.findViewById<ImageView>(R.id.iv_userImg))
        holder.binding.root.findViewById<TextView>(R.id.tv_userName).text =
            mListData[position].userName
        holder.binding.root.setOnClickListener({
            mViewModel?.setIsShowCallUserNumber("@:${mListData[position].userNumber}")
        })
    }
}